﻿using System;
using SEAM.Data;

namespace SEAM.Data.Provider
{
    /// <summary>
    /// Provides a way to implement a DataAccess connection provider that
    /// will provide a database connection through DataAccess class.
    /// 
    /// <example>
    /// 
    /// // SampleProvider1 will always provide a connection to the local 
    /// // SqlServer and requires no parameters.
    /// public class SampleProvider1 : IConnectionProvider
    /// {
    ///     public DataAccess GetDataAccess(params object[] args)
    ///     {
    ///         return new SqlDataAccess("Data Source=localhost;Initial Catalog=Northwind;Integrated Security=True");
    ///     }
    /// }
    /// 
    /// 
    /// // SampleProvider2 will always provide either SqlServer or Oracle connection based
    /// // on Mode passed in as a parameter.
    /// public class SampleProvider2 : IConnectionProvider
    /// {
    ///     public DataAccess GetDataAccess(params object[] args)
    ///     {
    ///         if (args != null && args.length != 1)
    ///             return null;
    ///         else if (((Mode)args[0]) == Mode.Development)
    ///         {
    ///             // Returns a connection to SqlServer to [devserver]
    ///             return new SqlDataAccess("Data Source=devserver;Integrated Security=True");
    ///         }
    ///         else if (((Mode)args[0]) == Mode.Production)
    ///         {
    ///             // Returns a connection to SqlServer to [prodserver]
    ///             return new SqlDataAccess("Data Source=prodserver;Integrated Security=True");
    ///         }
    ///         else if (((Mode)args[0]) == Mode.Warehouse)
    ///         {
    ///             // Returns a connection to OracleServer to [dwserver]
    ///             return new OracleDataAccess("Data Source=dwserver;Integrated Security=True");
    ///         }
    ///         else
    ///             return null;
    ///     }
    /// }
    /// 
    /// public enum Mode
    /// {
    ///     Development,
    ///     Production,
    ///     Warehouse
    /// }
    /// 
    /// </example>
    /// 
    /// </summary>
    public interface IConnectionProvider
    {
        /// <summary>
        /// Returns an instance of DataAccess based on parameters
        /// passed in by the users.
        /// </summary>
        /// <param name="args">
        /// An array of parameters used to provide appropriate 
        /// connection to the user
        /// </param>
        /// <returns>an instance of DataAccess class</returns>
        DataAccess GetDataAccess(params object[] args);
    }
}
